package com.vrv.app.cyberspace.modules.sys.controller;


import com.vrv.app.cyberspace.common.utils.JSONResult;
import com.vrv.app.cyberspace.common.validator.Assert;
import com.vrv.app.cyberspace.modules.sys.service.IBulletinApprovalTableService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sm
 * @since 2017-12-15
 */
@Api(description="今日快报审批流程")
@RestController
@RequestMapping("/sys/bulletinApproval")
public class BulletinApprovalTableController {
    @Autowired
    private IBulletinApprovalTableService bulletinApprovalTableService;

    @ApiOperation(value = "今日快报流程处理", produces = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "返回成功信息")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Integer", paramType = "path"),
            @ApiImplicitParam(name = "advice", value = "研判意见", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "approvalUserID", value = "请示人ID", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "1.转批2.同意3.退回", required = true, dataType = "Integer", paramType = "query"),
    })
    @PutMapping("/{id}")
    public JSONResult updateBulletinApproval(@PathVariable Integer id, String advice, String approvalUserID, Integer type){
        Assert.isNull(id,"id不能为空");
        Assert.isNull(type,"type不能为空");
        if (type==1){
            return bulletinApprovalTableService.addTodayBulletinApproval(id,advice,approvalUserID);
        }else if (type==2){
            return bulletinApprovalTableService.endTodayBulletinApproval(id,advice);
        }else if (type==3){
            return bulletinApprovalTableService.backTodayBulletinApproval(id,advice);
        }
        return JSONResult.renderError();
    }
}

